<?php
$p = json_decode(file_get_contents('payment.json'),true);
var_dump($p);
echo "<hr>";
echo $p['bill']['bill_id']."<br>";
echo $p['bill']['total_items']."<br>";
echo $p['bill']['total']."<br>";
echo $p['bill']['tax']."<br>";
echo $p['bill']['discount']."<br>";
echo $p['bill']['grand_tot']."<br>";
echo $p['bill']['paid']."<br>";

echo $p['bill']['change']."<br>";
echo $p['bill']['paidby']."<br>";
echo $p['bill']['card_num']."<br>";
echo $p['bill']['card_holder']."<br>";

echo $p['bill']['customer']."<br>";
echo $p['bill']['userid']."<br>";
echo $p['bill']['status']."<br>";
echo "<hr>";
$val = "('".$p['bill']['bill_id']."','".$p['bill']['tot_item']."','".$p['bill']['total']."','".$p['bill']['tax']."','".$p['bill']['discount']."','".$p['bill']['grand_tot']."','".$p['bill']['paid']."','".$p['bill']['change']."','".$p['bill']['paidby']."','".$p['bill']['card_num']."','".$p['bill']['card_holder']."','".$p['bill']['customer']."','".$p['bill']['userid']."','".$p['bill']['status']."','".$p['bill']['reff_id']."')";
echo "$val<hr>";

//--prints items :
$rows = $p['items'];
foreach($rows as $i=>$r_value) {
		$sql = "";
		$sql = "INSERT INTO `tb_orders` (`order_id`,`prod_id`,`qty`,`customer`,`user_id`,`status`,`bill_num`,`order_tag`) ";
		$sql .= " VALUES (";
		foreach($r_value as $j=>$j_value) {
			$sql .= "'".$rows[$i][$j]."',";			
		}
		$sql = substr($sql,0,-1); 
		$sql .= ")";
		//$result = @mysql_query($sql,$link);
		//if (!$result) {
		//	die('Error: ' . @mysql_error($link));
		//}
		echo "$sql<br>";
		//$tmp .= $sql;
}

?>